import { resolve } from 'path'
import { defineConfig } from 'vite'

/* Vite配置 */
import { buildConfig, createVitePlugins, cssConfig, proxyConfig } from './vite-setting/index'

const pathResolve = (dir: string) => resolve(__dirname, dir)

export default defineConfig({
  /* 公共基础路径 */
  base: '/',

  /* 路径别名 */
  resolve: {
    alias: {
      '@': pathResolve('./src'),
      assets: pathResolve('./src/assets')
    },
    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
  },

  /* css配置 */
  css: cssConfig,

  /* 服务配置 */
  server: proxyConfig,

  /* build配置 */
  build: buildConfig,

  plugins: createVitePlugins(resolve),

  define: {
    // enable hydration mismatch details in production build
    __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
  }
})
